﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace MobSoulWPhoneToolkit.Controls
{
    public partial class RepeatButton : UserControl
    {
        public RepeatButton()
        {
            InitializeComponent();
        }
        public event RoutedEventHandler RepeatedClick;

        private void Repeated_Click(object sender, RoutedEventArgs e)
        {
            if (RepeatedClick != null)
                RepeatedClick(this, new RoutedEventArgs());
        }
        RepeatButtonIcon icon = RepeatButtonIcon.Plus;
        public RepeatButtonIcon Icon
        {
            set { icon= value;
            if (value==RepeatButtonIcon.Plus)
            {
                noPressedMinus.Visibility = Visibility.Collapsed;
                pressedMinus.Visibility = Visibility.Collapsed;

                pressedPlus.Visibility = Visibility.Visible;
                nopressedplus.Visibility = Visibility.Visible;
            }
            else
            {                
                pressedPlus.Visibility = Visibility.Collapsed;
                nopressedplus.Visibility = Visibility.Collapsed;

                noPressedMinus.Visibility = Visibility.Visible;
                pressedMinus.Visibility = Visibility.Visible;
            }
            }
            get { return icon; }
        }

        
        private void repeatButton_ManipulationCompleted(object sender, ManipulationCompletedEventArgs e)
        {
            PressedGrid.Visibility = Visibility.Collapsed;
        }

        private void repeatButton_ManipulationStarted(object sender, ManipulationStartedEventArgs e)
        {
            PressedGrid.Visibility = Visibility.Visible;
        }

        //public static readonly DependencyProperty Iconproperty = DependencyProperty.Register("AppName", typeof(RepeatButtonIcon), typeof(RepeatButton), new PropertyMetadata(RepeatButtonIcon.Plus, onPropertychanged));
        //public RepeatButtonIcon Icon
        //{
        //    set { SetValue(Iconproperty, value); }
        //    get { return (RepeatButtonIcon)GetValue(Iconproperty); }
        //}
        //static void onPropertychanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
        //{
        //    RepeatButton app = sender as RepeatButton;
        //    if (args.Property == Iconproperty)
        //    {
        //        if (args.NewValue!=null )
        //        {
        //            if ((args.NewValue as RepeatButtonIcon) == RepeatButtonIcon.Plus)
        //            {
        //               // 
        //            }
        //            else
        //            {

        //            }
        //        }
        //    }
        //}
    }
    public enum RepeatButtonIcon
    {
        Plus,
        Minus
    }
}
